import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      // 将 /hospital5_war 开头的请求转发到后端
      '/hospital5_war': {  
        target: 'http://localhost:8080', // 后端地址
        changeOrigin: true, // 开启跨域
        rewrite: (path) => path.replace(/^\/hospital5_war/, '') // 移除前缀
      }
    }
  }
})